<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>银行业务管理系统 - 存款业务管理</title>
    <!-- 引入Tailwind CSS -->
    <script src="https://cdn.tailwindcss.com"></script>
    <!-- 引入Font Awesome -->
    <link href="https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/css/font-awesome.min.css" rel="stylesheet">
    <!-- 配置Tailwind -->
    <script>
        tailwind.config = {
            theme: {
                extend: {
                    colors: {
                        primary: '#1890ff',
                        secondary: '#40a9ff',
                        success: '#52c41a',
                        warning: '#faad14',
                        danger: '#ff4d4f',
                        info: '#8c8c8c',
                        light: '#fafafa',
                        dark: '#1f2937'
                    },
                    fontFamily: {
                        sans: ['Microsoft YaHei', 'Inter', 'sans-serif'],
                    },
                }
            }
        }
    </script>
    <style type="text/tailwindcss">
        @layer utilities {
            .content-auto {
                content-visibility: auto;
            }
            .card-shadow {
                box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
            }
            .card-hover {
                transition: all 0.3s ease;
            }
            .card-hover:hover {
                transform: translateY(-2px);
                box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
            }
            .btn-primary {
                @apply bg-primary text-white px-4 py-2 rounded-md hover:bg-secondary transition-colors duration-200;
            }
            .btn-secondary {
                @apply bg-white text-primary border border-primary px-4 py-2 rounded-md hover:bg-primary/5 transition-colors duration-200;
            }
            .btn-danger {
                @apply bg-danger text-white px-4 py-2 rounded-md hover:bg-danger/90 transition-colors duration-200;
            }
            .btn-warning {
                @apply bg-warning text-white px-4 py-2 rounded-md hover:bg-warning/90 transition-colors duration-200;
            }
            .input-control {
                @apply border border-gray-300 rounded-md px-3 py-2 focus:outline-none focus:ring-2 focus:ring-primary/50 focus:border-primary transition-all duration-200;
            }
            .table-row-hover {
                @apply hover:bg-gray-50 transition-colors duration-150;
            }
            .badge {
                @apply px-2 py-1 rounded-full text-xs font-medium;
            }
            .badge-success {
                @apply bg-success/10 text-success;
            }
            .badge-danger {
                @apply bg-danger/10 text-danger;
            }
            .badge-warning {
                @apply bg-warning/10 text-warning;
            }
        }
    </style>
</head>
<body class="bg-gray-50 text-gray-800 min-h-screen flex flex-col">
    <!-- 顶部导航 -->
    <header class="bg-primary text-white shadow-md">
        <div class="container mx-auto px-4 py-3 flex justify-between items-center">
            <div class="flex items-center space-x-2">
                <i class="fa fa-bank text-2xl"></i>
                <h1 class="text-xl font-semibold">银行业务管理系统</h1>
            </div>
            <div class="flex items-center space-x-6">
                <div class="relative">
                    <button class="flex items-center space-x-2 focus:outline-none">
                        <i class="fa fa-bell-o"></i>
                        <span class="absolute -top-1 -right-1 bg-danger text-white text-xs rounded-full h-4 w-4 flex items-center justify-center">3</span>
                    </button>
                </div>
                <div class="flex items-center space-x-2">
                    <img src="https://picsum.photos/id/1005/40/40" alt="用户头像" class="w-8 h-8 rounded-full object-cover">
                    <span>管理员</span>
                </div>
            </div>
        </div>
    </header>

    <!-- 主体内容 -->
    <main class="flex-1 overflow-auto p-6 bg-gray-50">
        <!-- 面包屑导航 -->
        <div class="mb-6 flex items-center text-sm text-gray-500">
            <a href="#" class="hover:text-primary">首页</a>
            <i class="fa fa-angle-right mx-2 text-xs"></i>
            <span class="text-gray-700">存款业务管理</span>
        </div>

        <!-- 页面标题 -->
        <div class="mb-6 flex flex-col md:flex-row md:items-center md:justify-between">
            <div>
                <h2 class="text-2xl font-semibold text-gray-800">存款业务管理</h2>
                <p class="text-gray-500 mt-1">管理所有存款业务类型信息</p>
            </div>
            <div class="mt-4 md:mt-0 flex space-x-3">
                <button id="addBusinessBtn" class="btn-primary flex items-center">
                    <i class="fa fa-plus mr-2"></i>添加存款业务
                </button>
                <button id="exportCsvBtn" class="btn-warning flex items-center">
                    <i class="fa fa-file-text-o mr-2"></i>导出CSV
                </button>
            </div>
        </div>

        <!-- 搜索和筛选区域 -->
        <div class="bg-white rounded-lg p-6 card-shadow mb-6">
            <div class="grid grid-cols-1 md:grid-cols-3 gap-6">
                <div>
                    <label class="block text-sm font-medium text-gray-700 mb-1">业务类型编号</label>
                    <div class="relative">
                        <input type="text" id="businessId" placeholder="输入业务编号" class="input-control w-full pl-10">
                        <i class="fa fa-hashtag absolute left-3 top-1/2 -translate-y-1/2 text-gray-400"></i>
                    </div>
                </div>
                <div>
                    <label class="block text-sm font-medium text-gray-700 mb-1">业务名称</label>
                    <div class="relative">
                        <input type="text" id="businessName" placeholder="输入业务名称" class="input-control w-full pl-10">
                        <i class="fa fa-font absolute left-3 top-1/2 -translate-y-1/2 text-gray-400"></i>
                    </div>
                </div>
                <div class="flex items-end">
                    <button id="searchBtn" class="btn-primary w-full">
                        <i class="fa fa-search mr-2"></i>搜索
                    </button>
                </div>
            </div>
        </div>

        <!-- 存款业务列表 -->
        <div class="bg-white rounded-lg p-6 card-shadow">
            <div class="flex justify-between items-center mb-6">
                <h3 class="font-semibold">存款业务列表</h3>
                <div class="text-sm text-gray-500" id="recordCount">共 0 条存款业务</div>
            </div>

            <div class="overflow-x-auto">
                <table class="min-w-full">
                    <thead>
                        <tr class="bg-gray-50 text-left">
                            <th class="py-3 px-4 text-xs font-medium text-gray-500 uppercase tracking-wider">
                                <input type="checkbox" id="selectAll" class="rounded text-primary focus:ring-primary">
                            </th>
                            <th class="py-3 px-4 text-xs font-medium text-gray-500 uppercase tracking-wider">业务类型编号</th>
                            <th class="py-3 px-4 text-xs font-medium text-gray-500 uppercase tracking-wider">业务名称</th>
                            <th class="py-3 px-4 text-xs font-medium text-gray-500 uppercase tracking-wider">业务描述</th>
                            <th class="py-3 px-4 text-xs font-medium text-gray-500 uppercase tracking-wider text-right">操作</th>
                        </tr>
                    </thead>
                    <tbody id="businessTableBody" class="divide-y divide-gray-200">
                        <!-- 存款业务数据将通过JavaScript动态生成 -->
                        <tr class="text-center">
                            <td colspan="5" class="px-6 py-12 text-gray-500">
                                <div class="flex flex-col items-center">
                                    <i class="fa fa-search text-4xl mb-4 text-gray-300"></i>
                                    <p>暂无存款业务记录，请添加或搜索</p>
                                </div>
                            </td>
                        </tr>
                    </tbody>
                </table>
            </div>

            <!-- 分页 -->
            <div class="mt-6 flex flex-col sm:flex-row items-center justify-between">
                <div class="text-sm text-gray-500 mb-4 sm:mb-0">
                    显示 <span id="startIndex">0</span> 到 <span id="endIndex">0</span> 条，共 <span id="totalRecords">0</span> 条记录
                </div>
                <div class="flex items-center space-x-1">
                    <button id="prevPage" class="px-3 py-1 rounded border border-gray-300 text-gray-500 hover:border-primary hover:text-primary disabled:opacity-50 disabled:cursor-not-allowed" disabled>
                        <i class="fa fa-chevron-left text-xs"></i>
                    </button>
                    <button id="nextPage" class="px-3 py-1 rounded border border-gray-300 text-gray-500 hover:border-primary hover:text-primary disabled:opacity-50 disabled:cursor-not-allowed" disabled>
                        <i class="fa fa-chevron-right text-xs"></i>
                    </button>
                </div>
            </div>
        </div>
    </main>

    <!-- 页脚 -->
    <footer class="bg-white border-t border-gray-200 py-4">
        <div class="container mx-auto px-4 text-center text-gray-500 text-sm">
            <p>咨询电话：123456 | 工作时间：工作日9:00-12:00,14:00-17:00</p>
            <p>© 2025 **银行 版权所有</p>
        </div>
    </footer>

    <!-- 添加存款业务模态框 -->
    <div id="addBusinessModal" class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 hidden">
        <div class="bg-white rounded-lg w-full max-w-md p-6 transform transition-all">
            <div class="flex justify-between items-center mb-4">
                <h3 class="font-semibold text-lg">添加存款业务</h3>
                <button id="closeAddModal" class="text-gray-400 hover:text-gray-600">
                    <i class="fa fa-times"></i>
                </button>
            </div>
            <form id="addBusinessForm">
                <div class="space-y-4">
                    <div>
                        <label class="block text-sm font-medium text-gray-700 mb-1">业务类型编号</label>
                        <input type="text" id="addBusinessId" placeholder="输入唯一业务编号" class="input-control w-full" required>
                        <div id="businessIdError" class="error-message hidden text-danger text-xs mt-1">业务编号已存在或格式不正确</div>
                    </div>
                    <div>
                        <label class="block text-sm font-medium text-gray-700 mb-1">业务名称</label>
                        <input type="text" id="addBusinessName" placeholder="输入业务名称" class="input-control w-full" required>
                    </div>
                    <div>
                        <label class="block text-sm font-medium text-gray-700 mb-1">业务描述</label>
                        <textarea id="addDescription" rows="3" class="input-control w-full" placeholder="输入业务描述信息"></textarea>
                    </div>
                </div>
                <div class="mt-6 flex justify-end space-x-3">
                    <button type="button" id="cancelAddBusiness" class="px-4 py-2 border border-gray-300 rounded-md text-gray-700 hover:bg-gray-50">取消</button>
                    <button type="submit" class="btn-primary">保存业务</button>
                </div>
            </form>
        </div>
    </div>

    <!-- 编辑存款业务模态框 -->
    <div id="editBusinessModal" class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 hidden">
        <div class="bg-white rounded-lg w-full max-w-md p-6 transform transition-all">
            <div class="flex justify-between items-center mb-4">
                <h3 class="font-semibold text-lg">编辑存款业务</h3>
                <button id="closeEditModal" class="text-gray-400 hover:text-gray-600">
                    <i class="fa fa-times"></i>
                </button>
            </div>
            <form id="editBusinessForm">
                <input type="hidden" id="editBusinessId">
                <div class="space-y-4">
                    <div>
                        <label class="block text-sm font-medium text-gray-700 mb-1">业务类型编号</label>
                        <input type="text" id="editBusinessIdInput" placeholder="业务编号" class="input-control w-full" disabled>
                    </div>
                    <div>
                        <label class="block text-sm font-medium text-gray-700 mb-1">业务名称</label>
                        <input type="text" id="editBusinessName" placeholder="输入业务名称" class="input-control w-full" required>
                    </div>
                    <div>
                        <label class="block text-sm font-medium text-gray-700 mb-1">业务描述</label>
                        <textarea id="editDescription" rows="3" class="input-control w-full" placeholder="输入业务描述信息"></textarea>
                    </div>
                </div>
                <div class="mt-6 flex justify-end space-x-3">
                    <button type="button" id="cancelEditBusiness" class="px-4 py-2 border border-gray-300 rounded-md text-gray-700 hover:bg-gray-50">取消</button>
                    <button type="submit" class="btn-primary">更新业务</button>
                </div>
            </form>
        </div>
    </div>

    <!-- 删除确认模态框 -->
    <div id="deleteModal" class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 hidden">
        <div class="bg-white rounded-lg w-full max-w-md p-6 transform transition-all">
            <div class="text-center mb-4">
                <div class="inline-flex items-center justify-center w-16 h-16 rounded-full bg-danger/10 mb-4">
                    <i class="fa fa-exclamation-triangle text-danger text-2xl"></i>
                </div>
                <h3 class="text-lg font-semibold">确认删除</h3>
                <p class="text-gray-500 mt-2">您确定要删除这条存款业务记录吗？此操作不可撤销。</p>
                <input type="hidden" id="deleteBusinessId">
                <p class="text-gray-700 mt-3 font-medium" id="deleteBusinessName"></p>
            </div>
            <div class="flex justify-center space-x-3">
                <button id="cancelDelete" class="px-4 py-2 border border-gray-300 rounded-md hover:bg-gray-50 transition-colors">
                    取消
                </button>
                <button id="confirmDelete" class="btn-danger">
                    确认删除
                </button>
            </div>
        </div>
    </div>

    <!-- 通知组件 -->
    <div id="notification" class="fixed top-4 right-4 z-50 max-w-xs bg-white rounded-lg shadow-lg p-4 transform translate-x-full transition-transform duration-300 flex items-start">
        <div id="notificationIcon" class="w-8 h-8 rounded-full flex items-center justify-center mr-3 bg-primary/10">
            <i class="fa fa-info text-primary"></i>
        </div>
        <div class="flex-1">
            <h4 id="notificationTitle" class="font-medium text-gray-900">通知标题</h4>
            <p id="notificationMessage" class="text-sm text-gray-500 mt-1">通知内容将显示在这里...</p>
        </div>
        <button id="closeNotification" class="text-gray-400 hover:text-gray-600 ml-2">
            <i class="fa fa-times"></i>
        </button>
    </div>

    <script>
        // 存款业务数据模型
        let businessData = [
            {
                id: 'DEPOSIT001',
                name: '活期存款',
                description: '活期存款是一种不限存期，凭银行卡或存折及预留密码可在银行营业时间内通过柜面或通过银行自助设备随时存取现金的服务。起存金额为1元，资金流动性高，适合日常收支使用。'
            },
            {
                id: 'DEPOSIT002',
                name: '定期存款',
                description: '定期存款是指存款人在保留所有权的条件下，把使用权暂时转让给银行的资金或货币。定期存款期限一般为3个月、6个月、1年、2年、3年和5年，期限越长利率越高。'
            },
            {
                id: 'DEPOSIT003',
                name: '通知存款',
                description: '通知存款是一种不约定存期、支取时需提前通知银行、约定支取日期和金额方能支取的存款。个人通知存款不论实际存期多长，按存款人提前通知的期限长短划分为一天通知存款和七天通知存款两个品种。'
            },
            {
                id: 'DEPOSIT004',
                name: '协定存款',
                description: '协定存款是对公客户与银行签订协定存款合同，双方约定对公客户保留一定金额的存款以应付日常结算，此部分按普通活期利率计付利息，超过定额金额的那部分存款按协定存款利率计付利息。'
            }
        ];

        // 分页参数
        let currentPage = 1;
        const itemsPerPage = 10;
        let filteredData = [...businessData];

        // 页面加载完成后执行
        document.addEventListener('DOMContentLoaded', function() {
            // 初始化事件监听
            initEventListeners();

            // 加载存款业务数据
            loadBusinesses();
        });

        // 初始化事件监听
        function initEventListeners() {
            // 添加存款业务按钮
            document.getElementById('addBusinessBtn').addEventListener('click', showAddBusinessModal);
            document.getElementById('closeAddModal').addEventListener('click', hideAddBusinessModal);
            document.getElementById('cancelAddBusiness').addEventListener('click', hideAddBusinessModal);
            document.getElementById('addBusinessForm').addEventListener('submit', saveBusiness);

            // 编辑存款业务按钮（动态绑定）
            document.getElementById('businessTableBody').addEventListener('click', function(e) {
                if (e.target.closest('.edit-btn')) {
                    const businessId = e.target.closest('.edit-btn').dataset.id;
                    showEditBusinessModal(businessId);
                }
            });

            // 删除存款业务按钮（动态绑定）
            document.getElementById('businessTableBody').addEventListener('click', function(e) {
                if (e.target.closest('.delete-btn')) {
                    const businessId = e.target.closest('.delete-btn').dataset.id;
                    showDeleteModal(businessId);
                }
            });

            // 搜索按钮
            document.getElementById('searchBtn').addEventListener('click', searchBusinesses);

            // 导出CSV按钮
            document.getElementById('exportCsvBtn').addEventListener('click', exportToCsv);

            // 编辑存款业务模态框
            document.getElementById('closeEditModal').addEventListener('click', hideEditBusinessModal);
            document.getElementById('cancelEditBusiness').addEventListener('click', hideEditBusinessModal);
            document.getElementById('editBusinessForm').addEventListener('submit', updateBusiness);

            // 删除模态框按钮
            document.getElementById('cancelDelete').addEventListener('click', hideDeleteModal);
            document.getElementById('confirmDelete').addEventListener('click', deleteBusiness);

            // 分页按钮
            document.getElementById('prevPage').addEventListener('click', prevPage);
            document.getElementById('nextPage').addEventListener('click', nextPage);

            // 全选复选框
            document.getElementById('selectAll').addEventListener('click', toggleSelectAll);

            // 通知关闭按钮
            document.getElementById('closeNotification').addEventListener('click', closeNotification);
        }

        // 加载存款业务数据
        function loadBusinesses() {
            const start = (currentPage - 1) * itemsPerPage;
            const end = start + itemsPerPage;
            const currentPageData = filteredData.slice(start, end);

            const tableBody = document.getElementById('businessTableBody');
            let html = '';

            if (currentPageData.length === 0 && filteredData.length > 0) {
                html = `
                    <tr class="text-center">
                        <td colspan="5" class="px-6 py-12 text-gray-500">
                            <div class="flex flex-col items-center">
                                <i class="fa fa-search text-4xl mb-4 text-gray-300"></i>
                                <p>没有找到符合条件的存款业务</p>
                            </div>
                        </td>
                    </tr>
                `;
            } else if (currentPageData.length === 0 && filteredData.length === 0) {
                html = `
                    <tr class="text-center">
                        <td colspan="5" class="px-6 py-12 text-gray-500">
                            <div class="flex flex-col items-center">
                                <i class="fa fa-search text-4xl mb-4 text-gray-300"></i>
                                <p>暂无存款业务记录，请添加或搜索</p>
                            </div>
                        </td>
                    </tr>
                `;
            } else {
                currentPageData.forEach(business => {
                    html += `
                        <tr class="table-row-hover">
                            <td class="py-3 px-4">
                                <input type="checkbox" class="business-checkbox" data-id="${business.id}">
                            </td>
                            <td class="py-3 px-4">
                                <div class="text-sm text-gray-900">${business.id}</div>
                            </td>
                            <td class="py-3 px-4">
                                <div class="text-sm text-gray-900">${business.name}</div>
                            </td>
                            <td class="py-3 px-4">
                                <div class="text-sm text-gray-700 line-clamp-2">${business.description}</div>
                            </td>
                            <td class="py-3 px-4 text-right text-sm font-medium">
                                <button class="edit-btn text-primary hover:text-primary/80 mr-2" data-id="${business.id}" title="编辑">
                                    <i class="fa fa-pencil"></i>
                                </button>
                                <button class="delete-btn text-danger hover:text-danger/80" data-id="${business.id}" title="删除">
                                    <i class="fa fa-trash"></i>
                                </button>
                            </td>
                        </tr>
                    `;
                });
            }

            tableBody.innerHTML = html;
            updatePagination();
            updateRecordCount();
        }

        // 更新分页信息
        function updatePagination() {
            const totalPages = Math.ceil(filteredData.length / itemsPerPage);
            const start = (currentPage - 1) * itemsPerPage + 1;
            const end = Math.min(currentPage * itemsPerPage, filteredData.length);

            document.getElementById('startIndex').textContent = filteredData.length > 0 ? start : 0;
            document.getElementById('endIndex').textContent = end;
            document.getElementById('totalRecords').textContent = filteredData.length;
            document.getElementById('recordCount').textContent = `共 ${filteredData.length} 条存款业务`;

            // 更新分页按钮状态
            document.getElementById('prevPage').disabled = currentPage === 1;
            document.getElementById('nextPage').disabled = currentPage >= totalPages;
        }

        // 更新记录计数
        function updateRecordCount() {
            document.getElementById('recordCount').textContent = `共 ${filteredData.length} 条存款业务`;
        }

        // 上一页
        function prevPage() {
            if (currentPage > 1) {
                currentPage--;
                loadBusinesses();
            }
        }

        // 下一页
        function nextPage() {
            const totalPages = Math.ceil(filteredData.length / itemsPerPage);
            if (currentPage < totalPages) {
                currentPage++;
                loadBusinesses();
            }
        }

        // 显示添加存款业务模态框
        function showAddBusinessModal() {
            document.getElementById('addBusinessModal').classList.remove('hidden');
            document.getElementById('addBusinessModal').querySelector('div').classList.add('scale-100');
            document.getElementById('addBusinessModal').querySelector('div').classList.remove('scale-95');
            document.getElementById('businessIdError').classList.add('hidden');
            document.getElementById('addBusinessForm').reset();
        }

        // 隐藏添加存款业务模态框
        function hideAddBusinessModal() {
            document.getElementById('addBusinessModal').querySelector('div').classList.add('scale-95');
            document.getElementById('addBusinessModal').querySelector('div').classList.remove('scale-100');
            setTimeout(() => {
                document.getElementById('addBusinessModal').classList.add('hidden');
            }, 200);
        }

        // 保存存款业务记录
        function saveBusiness(e) {
            e.preventDefault();

            const businessId = document.getElementById('addBusinessId').value;
            const businessName = document.getElementById('addBusinessName').value;
            const description = document.getElementById('addDescription').value;

            // 验证表单
            if (!businessId) {
                showNotification('错误', '请输入业务类型编号', 'error');
                return;
            }

            if (!businessName) {
                showNotification('错误', '请输入业务名称', 'error');
                return;
            }

            // 检查业务编号是否已存在
            if (businessData.some(business => business.id === businessId)) {
                document.getElementById('businessIdError').classList.remove('hidden');
                return;
            }

            // 创建新存款业务记录
            const newBusiness = {
                id: businessId,
                name: businessName,
                description: description
            };

            // 添加到数据数组
            businessData.push(newBusiness);
            filteredData = [...businessData];
            currentPage = 1;

            // 刷新表格
            loadBusinesses();

            // 隐藏模态框
            hideAddBusinessModal();

            // 显示成功通知
            showNotification('成功', '存款业务添加成功', 'success');
        }

        // 显示编辑存款业务模态框
        function showEditBusinessModal(businessId) {
            const business = businessData.find(b => b.id === businessId);
            if (!business) return;

            document.getElementById('editBusinessId').value = business.id;
            document.getElementById('editBusinessIdInput').value = business.id;
            document.getElementById('editBusinessName').value = business.name;
            document.getElementById('editDescription').value = business.description;

            document.getElementById('editBusinessModal').classList.remove('hidden');
            document.getElementById('editBusinessModal').querySelector('div').classList.add('scale-100');
            document.getElementById('editBusinessModal').querySelector('div').classList.remove('scale-95');
        }

        // 隐藏编辑存款业务模态框
        function hideEditBusinessModal() {
            document.getElementById('editBusinessModal').querySelector('div').classList.add('scale-95');
            document.getElementById('editBusinessModal').querySelector('div').classList.remove('scale-100');
            setTimeout(() => {
                document.getElementById('editBusinessModal').classList.add('hidden');
            }, 200);
        }

        // 更新存款业务记录
        function updateBusiness(e) {
            e.preventDefault();

            const businessId = document.getElementById('editBusinessId').value;
            const businessName = document.getElementById('editBusinessName').value;
            const description = document.getElementById('editDescription').value;

            // 验证表单
            if (!businessName) {
                showNotification('错误', '请输入业务名称', 'error');
                return;
            }

            // 更新数据
            const index = businessData.findIndex(b => b.id === businessId);
            if (index !== -1) {
                businessData[index] = {
                    ...businessData[index],
                    name: businessName,
                    description: description
                };
                filteredData = [...businessData];
                currentPage = 1;

                // 刷新表格
                loadBusinesses();

                // 隐藏模态框
                hideEditBusinessModal();

                // 显示成功通知
                showNotification('成功', '存款业务更新成功', 'success');
            }
        }

        // 显示删除模态框
        function showDeleteModal(businessId) {
            const business = businessData.find(b => b.id === businessId);
            if (!business) return;

            document.getElementById('deleteBusinessId').value = business.id;
            document.getElementById('deleteBusinessName').textContent = `即将删除: ${business.name}`;

            document.getElementById('deleteModal').classList.remove('hidden');
            document.getElementById('deleteModal').querySelector('div').classList.add('scale-100');
            document.getElementById('deleteModal').querySelector('div').classList.remove('scale-95');
        }

        // 隐藏删除模态框
        function hideDeleteModal() {
            document.getElementById('deleteModal').querySelector('div').classList.add('scale-95');
            document.getElementById('deleteModal').querySelector('div').classList.remove('scale-100');
            setTimeout(() => {
                document.getElementById('deleteModal').classList.add('hidden');
            }, 200);
        }

        // 删除存款业务记录
        function deleteBusiness() {
            const businessId = document.getElementById('deleteBusinessId').value;
            businessData = businessData.filter(business => business.id !== businessId);
            filteredData = [...businessData];
            currentPage = 1;

            // 刷新表格
            loadBusinesses();

            // 隐藏模态框
            hideDeleteModal();

            // 显示成功通知
            showNotification('成功', '存款业务删除成功', 'success');
        }

        // 搜索存款业务记录
        function searchBusinesses() {
            const businessId = document.getElementById('businessId').value.trim();
            const businessName = document.getElementById('businessName').value.trim();

            // 过滤数据
            filteredData = businessData.filter(business => {
                const matchId = !businessId || business.id.includes(businessId);
                const matchName = !businessName || business.name.includes(businessName);
                return matchId && matchName;
            });

            currentPage = 1;
            loadBusinesses();
        }

        // 导出为CSV
        function exportToCsv() {
            if (filteredData.length === 0) {
                showNotification('提示', '没有可导出的存款业务记录', 'warning');
                return;
            }

            // 构建CSV内容
            let csvContent = "业务类型编号,业务名称,业务描述\n";
            filteredData.forEach(business => {
                csvContent += `"${business.id}","${business.name}","${business.description.replace(/\n/g, ' ')}"\n`;
            });

            // 创建CSV文件
            const blob = new Blob([csvContent], { type: 'text/csv;charset=utf-8;' });
            const url = URL.createObjectURL(blob);
            const link = document.createElement("a");
            link.setAttribute("href", url);
            link.setAttribute("download", `存款业务记录_${new Date().toISOString().slice(0, 10)}.csv`);
            document.body.appendChild(link);
            link.click();
            document.body.removeChild(link);

            // 显示成功通知
            showNotification('成功', '存款业务记录导出成功', 'success');
        }

        // 全选/取消全选
        function toggleSelectAll() {
            const selectAll = document.getElementById('selectAll');
            const checkboxes = document.querySelectorAll('.business-checkbox');

            checkboxes.forEach(checkbox => {
                checkbox.checked = selectAll.checked;
            });
        }

        // 显示通知
        function showNotification(title, message, type = 'info') {
            const notification = document.getElementById('notification');
            const notificationTitle = document.getElementById('notificationTitle');
            const notificationMessage = document.getElementById('notificationMessage');
            const notificationIcon = document.getElementById('notificationIcon');

            // 设置通知内容
            notificationTitle.textContent = title;
            notificationMessage.textContent = message;

            // 设置通知类型样式
            notificationIcon.className = 'w-8 h-8 rounded-full flex items-center justify-center mr-3';
            let iconClass = 'fa fa-info';
            let bgClass = 'bg-primary/10';

            if (type === 'success') {
                iconClass = 'fa fa-check';
                bgClass = 'bg-success/10';
            } else if (type === 'warning') {
                iconClass = 'fa fa-exclamation';
                bgClass = 'bg-warning/10';
            } else if (type === 'error') {
                iconClass = 'fa fa-times';
                bgClass = 'bg-danger/10';
            }

            notificationIcon.className = `${bgClass} w-8 h-8 rounded-full flex items-center justify-center mr-3`;
            notificationIcon.innerHTML = `<i class="fa ${iconClass} text-${type === 'error' ? 'danger' : type === 'warning' ? 'warning' : type === 'success' ? 'success' : 'primary'}"></i>`;

            // 显示通知
            notification.classList.remove('translate-x-full');

            // 3秒后自动关闭
            setTimeout(closeNotification, 3000);
        }

        // 关闭通知
        function closeNotification() {
            const notification = document.getElementById('notification');
            notification.classList.add('translate-x-full');
        }
    </script>
</body>
</html>